import {
  Controller,
  Post,
  // UploadedFile, UseInterceptors,
  Body,
} from '@nestjs/common';
// import { FileInterceptor } from '@nestjs/platform-express';
import { PermissionOptional } from '../core/decorators/permission-optional.decorator';

// import { diskStorage } from 'multer';
// import { extname } from 'path';
// import * as fs from 'fs';
// import { app } from 'electron'
// import path from 'path';
import { FileService } from './file.service';

@Controller('file')
export class FileController {
  constructor(private readonly fileService: FileService) {}

  @PermissionOptional()
  @Post('upload')
  // @UseInterceptors(FileInterceptor('file'))
  async uploadFile(@Body() dto) {
    const fileUrl = await this.fileService.uploadFile(dto);

    return { url: fileUrl };
  }

  @PermissionOptional()
  @Post('uploadInterface')
  // @UseInterceptors(FileInterceptor('file'))
  async uploadInterface(@Body() dto) {
    const fileUrl = await this.fileService.uploadInterface(dto);

    return { url: fileUrl };
  }
}
